package com.example.demo.entity;

import javax.persistence.*;
import java.util.List;

/**
 * Created by pengwan on 2017/7/31.
 */
@Entity
@Table(name = "t_order")
public class Order extends EntityId {
    @Embedded
    private Address address;
    @ManyToOne
    @JoinColumn(name = "customer_id")
    // 单向，确保fetch join后，无需再select customer表
    private Customer customer;
    @OneToMany
    @JoinColumn(name = "order_id")
    private List<Item> items;

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public List<Item> getItems() {
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }
}
